package com.example.exporttemplate.controller;

import com.example.exporttemplate.service.EasyExcelExportService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 *
 * 阿里巴巴easyexcel导出controller
 *
 * @author liulindong
 * @version 2023/12/11 20:41
 */
@RequestMapping("/easyexcel_export")
@RestController
public class EasyExcelExportController {


    private final EasyExcelExportService easyExcelExportService;

    public EasyExcelExportController(EasyExcelExportService easyExcelExportService) {
        this.easyExcelExportService = easyExcelExportService;
    }


    /**
     * 简单的注解导出
     */
    @GetMapping("/simple_annotation_export")
    public void simpleAnnotationExport(HttpServletResponse response) {
        easyExcelExportService.simpleAnnotationExport(response);
    }


    /**
     * 通过模板导出excel
     */
    @GetMapping("/template_export")
    public void templateExport(HttpServletResponse response) {
        easyExcelExportService.templateExport(response);
    }


    /**
     * 无实体类的导出
     */
    @GetMapping("/no_entity_export")
    public void noEntityExport(HttpServletResponse response) {
        easyExcelExportService.noEntityExport(response);
    }
}
